package com.ruoyi.performance.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.ruoyi.performance.mapper.SysPerformanceTypeMapper;
import com.ruoyi.performance.domain.SysPerformanceType;
import com.ruoyi.performance.service.ISysPerformanceTypeService;

/**
 * 中间表Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-03-24
 */
@Service
public class SysPerformanceTypeServiceImpl implements ISysPerformanceTypeService 
{
    @Autowired
    private SysPerformanceTypeMapper sysPerformanceTypeMapper;
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 查询中间表
     * 
     * @param id 中间表主键
     * @return 中间表
     */
    @Override
    public SysPerformanceType selectSysPerformanceTypeById(Long id)
    {
        return sysPerformanceTypeMapper.selectSysPerformanceTypeById(id);
    }

    /**
     * 查询中间表列表
     * 
     * @param sysPerformanceType 中间表
     * @return 中间表
     */
    @Override
    public List<SysPerformanceType> selectSysPerformanceTypeList(SysPerformanceType sysPerformanceType)
    {
        return sysPerformanceTypeMapper.selectSysPerformanceTypeList(sysPerformanceType);
    }

    /**
     * 新增中间表
     * 
     * @param sysPerformanceType 中间表
     * @return 结果
     */
    @Override
    public int insertSysPerformanceType(SysPerformanceType sysPerformanceType)
    {
        sysPerformanceType.setCreateTime(DateUtils.getNowDate());
        return sysPerformanceTypeMapper.insertSysPerformanceType(sysPerformanceType);
    }

    /**
     * 修改中间表
     * 
     * @param sysPerformanceType 中间表
     * @return 结果
     */
    @Override
    public int updateSysPerformanceType(SysPerformanceType sysPerformanceType)
    {
        return sysPerformanceTypeMapper.updateSysPerformanceType(sysPerformanceType);
    }

    /**
     * 批量删除中间表
     * 
     * @param ids 需要删除的中间表主键
     * @return 结果
     */
    @Override
    public int deleteSysPerformanceTypeByIds(Long[] ids)
    {
        return sysPerformanceTypeMapper.deleteSysPerformanceTypeByIds(ids);
    }

    /**
     * 删除中间表信息
     * 
     * @param id 中间表主键
     * @return 结果
     */
    @Override
    public int deleteSysPerformanceTypeById(Long id)
    {
        return sysPerformanceTypeMapper.deleteSysPerformanceTypeById(id);
    }

    @Override
    public List<SysPerformanceType> getTeacherType() {
        return sysPerformanceTypeMapper.getTeacherType();
    }

    @Override
    public List<SysPerformanceType> getall() {
        List<SysPerformanceType> teacherType = sysPerformanceTypeMapper.getTeacherType();
        Object o = redisTemplate.opsForValue().get("teacher-type");
        if(o==null){
            redisTemplate.opsForValue().set("teacher-type",teacherType);
        }

        return teacherType;
    }
}
